package by.grsu.as.page;

import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.spring.injection.annot.SpringBean;

import by.grsu.as.dao.DaoCar;
import by.grsu.as.model.Car;


@SuppressWarnings("serial")
public class ListCarsPage extends BasePage {

	@SpringBean
	private DaoCar carDao;

	public ListCarsPage() {
		super();

		final List<Car> cars = carDao.findAll();

		add(new ListView<Car>("list", cars) {
			@Override
			protected void populateItem(final ListItem<Car> item) {
				final Car car = item.getModelObject();
				item.add(new Label("car", car.getName()));
				item.add(new Label("color", car.getColor()));
				item.add(new Label("volume", String.valueOf(car.getVolume())));
				item.add(new Label("koeff", String.valueOf(car.getKoeff())));
				/*
				 * item.add(new Link<Car>("editLink",new Model<Car>(car)){
				 * 
				 * @Override public void onClick(){ setResponsePage(new
				 * EditTicketRequest(car)); } });
				 */
			}
		});
		/*
		 * add(new Link<Car>("createLink", new Model<Car>(new Car())) {
		 * 
		 * @Override public void onClick() { setResponsePage(new
		 * EditCar(getModelObject())); } });
		 */
	}
}
